<script setup>
	import {
		ref
	} from 'vue';

	const num = ref(1);
	const color = ref("#ddd");
	const isLoading = ref(true)

	function onClick() {
		num.value++;
		color.value = "#" + String(Math.random()).substring(3,
			9); //substring(beginIndex,endIndex) 方法返回字符串的子字符串  beginIndex--起始索引（包括）, 索引从0开始。endIndex--结束索引（不包括）
	}

	function onChange(e) {
		isLoading.value = e.detail.value
	}
</script>
<template>
	<view class="box" @click="onClick" :style="{backgroundColor:color}">
		{{num}}
	</view>
	<switch checked @change="onChange" />
	<button type="primary" :loading="isLoading">按钮</button>
	<view>
		<navigator url="/pages/demo4/demo4">跳转到demo4</navigator>
	</view>
</template>
<style lang="scss" scoped>
	.box {
		width: 200px;
		height: 200px;
		background-color: orange;
	}
</style>